package cn.com.connext.scrm.web.rest.enums;

import java.util.Arrays;

/**
 * 卡券来源
 */
public enum CardCouponSource {

    PRODUCT("1", "积分商品"),
    PRIZE_GOOD("2", "奖品"),
    ACTIVITY("3", "组合券包");

    private String code;
    private String name;

    CardCouponSource(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据Code获取枚举
     *
     * @param code
     * @return
     */
    public static CardCouponSource getByCode(String code) {
        return Arrays.stream(values())
            .filter(em -> em.getCode().equals(code))
            .findAny()
            .orElse(null);
    }
}
